package cn.tuling.controllers;

import cn.tuling.entity.DO.Order;
import cn.tuling.entity.DO.Product;
import cn.tuling.feign.FeignProductFeignClient;
import cn.tuling.services.OrderServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

@RestController
public class OrderController {

    @Autowired
    private FeignProductFeignClient productFeignClient;

    @Autowired
    private OrderServiceImpl orderService;

    @GetMapping("/order/{oid}")
    public Order getOrder(@PathVariable Integer oid) {
        Product product = productFeignClient.getProduct(oid);
        throw new RuntimeException("test");

        //return new Order(oid, "奇怪的订单", product, "支付完成");
    }

    @GetMapping("/order/list")
    public List<Order> getOrders() {
        return Collections.EMPTY_LIST;
    }


    @GetMapping("/link/v1")
    public String testLinkV1() {
        return orderService.common();
    }

    @GetMapping("/link/v2")
    public String testLinkV2() {
        return orderService.common();
    }
}
